{extend name="base"/}
{block name="css"}
<link rel="stylesheet" href="__ADMIN__/css/goods_order.css">
<style>
        .layui-body {
            position: absolute;
            left: 120px;
            right: 0;
            top: 20px;
            bottom: 0;
            z-index: 998;
            width: auto;
            overflow: hidden;
            overflow-y: auto;
            box-sizing: border-box;
        }
    </style>
{/block}
{block name="content"}

<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-lg12">
            <fieldset class="layui-elem-field">
                <legend>编辑分类</legend>
                <div class="layui-field-box">
                    <form id="myForm" class="layui-form" enctype="multipart/form-data">
                        <div class="layui-form-item">
                            <label class="layui-form-label">所需积分</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input dataIntegral" name="integral" value="{$info.integral}" lay-verify="required"  placeholder="所需积分">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">兑换的余额</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input dataIntegral" name="balance" value="{$info.balance}" lay-verify="required"  placeholder="兑换的余额">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" name="id" value="{$info.id}"/>
                                 <input type="button"  lay-submit="" lay-filter="addAbout" style="width: 100px;height: 45px;text-align: center;line-height: 45px;border: none; background: #009688; color: #fff;border-radius: 2px;" value="{:lang('确认保存')}" class="" id="submit">
                            </div>
                        </div>

                    </form>
                </div>
            </fieldset>
        </div>
    </div>
</div>




{/block}
{block name="js"}
<script type="text/javascript" src="__SHOP__/js/jquery.form.js"></script>
<script type="text/javascript" src="__SHOP__/js/swiper.min.js"></script>
<script type="text/javascript" src="__SHOP__/js/layui/layui.js"></script>
<script>
    $(function () {
        layui.config({
            base: "/static/backend/js/"
        }).use(['form', 'layer', 'jquery', 'layedit', 'upload'], function () {
            var form = layui.form,
                    layer = parent.layer === undefined ? layui.layer : parent.layer,
                    upload = layui.upload,
                    layedit = layui.layedit,
                    $ = layui.jquery;
            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo1', {
                uploadImage: {
                    url: '/backend/goods/uploadImg/'
                    ,type: 'post'
                }
            });
            form.on("submit(addAbout)", function (data) {
                data.field.content = layedit.getContent(editIndex);

                var formdom = $('#myForm')[0]
                        ,formdata = new FormData(formdom);
                $.ajax({
                    url: '/backend/redeem/redeem_edit',
                    type: 'POST',
                    data: formdata,
                    processData: false, // jQuery不要去处理发送的数据
                    contentType: false, // jQuery不要去设置Content-Type请求头
                    success: function(res) {
                        console.log(res);
                        if(res.code==1){
                            layer.msg(res.msg, {
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                setTimeout(parent.location.reload(),3000);
                            });
                            //刷新父页面

                        }else{
                            top.layer.msg(res.msg);
                        }
                    }

                });


                return false;
            })

        });
    })
</script>
{/block}